package com.demo.flight.service.impl;

import com.demo.flight.entity.Seat;
import com.demo.flight.mapper.SeatMapper;
import com.demo.flight.service.SeatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ssy
 * @create 2022-03-24 16:57
 */

@Service
public class SeatServiceImpl implements SeatService {
    
    @Autowired
    private SeatMapper seatMapper;
    
    @Override
    public List<Seat> getAllAvailable(Integer flightId) {
        if (flightId == null) {
            return new ArrayList<>();
        }
        return seatMapper.selectAllAvailable(flightId);
    }
    
    @Override
    public boolean checkSeatAvailable(Integer seatId) {
        if (seatId == null) {
            return false;
        }
        return "yes".equals(seatMapper.checkSeatState(seatId));
    }
}
